package leetcode.动态规划.middle;

import java.util.Arrays;

/**
 * @author wangmaolin1
 * @date 2023/11/15 22:37
 */
public class _253 {
    int minMeetingRooms(int[][] meetings){
        int []start= new int[meetings.length];
        int []end=new int[meetings.length];
        for (int i = 0; i < meetings.length; i++) {
            start[i] = meetings[i][0];
            end[i] = meetings[i][1];
        }
        Arrays.sort(start);
        Arrays.sort(end);
        int l=0;
        int r=0;
        int res=0;
        int count=0;
        while ( l <meetings.length && r<meetings.length){
            if (start[l]<end[r]){
                count++;
                l++;
            }else {
                count--;
                r++;
            }
            res=Math.max(res,count);
        }
        return  res;
    }
}
